package org.ncibi.cytoscape.metscape.network;

import org.ncibi.cytoscape.metscape.data.Attributes;
import org.ncibi.metab.network.node.MetabolicNode;

import cytoscape.CyNode;
import cytoscape.Cytoscape;

public abstract class AbstractNodeTranslator implements NodeTranslator
{
    protected abstract void addAttributes(String id, MetabolicNode node);
    protected abstract String getCanonicalName(MetabolicNode node);

    @Override
    public CyNode toCyNode(MetabolicNode node)
    {
        String id = node.getId();
        CyNode cyNode = Cytoscape.getCyNode(id);
        cyNode = Cytoscape.getCyNode(id,true);
        addCommonAttributes(id,node);
        addAttributes(id,node);
        return cyNode;
    }

	private void addCommonAttributes(String id, MetabolicNode node) {
		Attributes.node.setAttribute(id, "Type", node.getType().toDisplayName());
		Attributes.node.setAttribute(id, "canonicalName", getCanonicalName(node));
	}
   
}
